package ar.edu.utn.frgp.banco.servlets;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ar.edu.utn.frgp.banco.domain.Cliente;
import ar.edu.utn.frgp.banco.service.RecursoServiceCliente;
import ar.edu.utn.frgp.banco.service.impl.RecursoServiceClienteImpl;

/**
 * Servlet implementation class ClienteServlet
 */
public class AltaClienteServlet extends GenericServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public AltaClienteServlet() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public void realizarAccion(HttpServletRequest req, HttpServletResponse resp) throws Exception {
		
		Cliente cl = new Cliente();
		cl.setDni(Integer.parseInt(req.getParameter("dni")));
		cl.setNombre(req.getParameter("nombre"));
		cl.setApellido(req.getParameter("apellido"));
		cl.setDireccion(req.getParameter("direccion"));
		cl.setEmail(req.getParameter("email"));
		cl.setEstado(1);
		
		RecursoServiceCliente service = new RecursoServiceClienteImpl();
		service.crearCliente(cl);
		RequestDispatcher dispatcher = req.getRequestDispatcher("menucliente.jsp");
		dispatcher.forward(req, resp);
		
	}
	
}
